package com.coocaa.ops.plus.core.third.dmp;

import com.coocaa.ops.plus.core.third.ThirdServiceProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.net.URI;
import java.net.URISyntaxException;
import java.util.Map;

/**
 * @author tangminghong
 * @date 2020-06-18
 */
@Service
public class DmpFeignClientService {
    @Autowired
    private DmpFeignClient dmpFeignClient;

    @Autowired
    private ThirdServiceProperties thirdServiceProperties;

    /**
     * 获取dmp策略信息
     *
     * @param params
     * @return
     */
    public String getDmpPolicyList(Map<String, String> params) {
        try {
            return dmpFeignClient.getDmpPolicyList(
                    new URI(thirdServiceProperties.getDmpServiceUrl()),
                    params
            );
        } catch (URISyntaxException e) {
            return "";
        }
    }

    /**
     * 获取dmp人群信息
     *
     * @param params
     * @return
     */
    public String getCrowdList(Map<String, String> params) {
        try {
            return dmpFeignClient.getCrowdList(
                    new URI(thirdServiceProperties.getDmpServiceUrl()),
                    params
            );
        } catch (URISyntaxException e) {
            return "";
        }
    }
}
